<template>
  <smart-page>
    <template #search>
      <smart-search :query-array="ATTEND_SEARCH" @on-handler="onSearch"/>
    </template>
    <a-table v-model:selectedKeys="selectedKeys"
             :table-layout-fixed="theme.layoutFixed"
             :row-selection="rowSelection"
             :columns="ATTEND_COLUMNS"
             :row-key="rowKey"
             :column-resizable="theme.resizable"
             :bordered="theme.bordered"
             :stripe="theme.stripe"
             :sticky-header="theme.sticky"
             :hoverable="theme.hoverAble"
             :pagination="pagination"
             :loading="theme.loading"
             :data="dataSource"
             @page-change="onPageChange"
             @page-size-change="onPageSizeChange">
      <template #action="{ record }">
<!--        <a-link   @click="toLink(record)">邀请记录</a-link>-->
      </template>
    </a-table>


  </smart-page>
</template>
<script lang="ts" setup name="pop-activity-record">
import {onMounted} from 'vue';

import {ATTEND_SEARCH} from '../resource/search'
import {ATTEND_COLUMNS} from "../resource/colums";
import {TablePage} from "@/libs/core";
import {PopActivityHttp} from "../resource/http";

import router from "@/libs/router";
import {Acl} from "@/libs/acl";

const pageConfig = {title: '参与记录', rowKey: 'id', nameKey: 'title'}
const {getAttendPage} = PopActivityHttp
const tablePage = new TablePage(pageConfig).setFetchXhr(getAttendPage).setPermission(Acl.POP_C2C_ATTEND_PAGE_LIST);
const {theme, pagination, rowKey, dataSource, rowSelection, selectedKeys} = tablePage
const {onFetch, onPageChange, onPageSizeChange, onSearch} = tablePage
onMounted(() => {
  const {query} = router.currentRoute.value
  if (query?.activityId !== undefined) tablePage.searchData.value.activityId = query.activityId
  onFetch()
})

const toLink = (record: { activity: { id: any; }; member: { id: any; }; }) => {

  router.push({
    path: '/pop/activity/record',
    query: {
      activityId: record.activity.id,
      inviterId: record.member.id
    }
  })
}
</script>

